<?php 

include '../function.php';

$str ="www.xuebingsi.com,www.baidu.com";//要操作的字符串


$preg = "/(xuebingsi|baidu)/";//规则 //原子组


// $c = preg_match($preg , $str);
// 
$c =preg_replace($preg, "<span style='color:red'>$1</span>", $str);


echo $c;

var_dump($str);



$str = "15925139194";

$preg = "/^[1](3[0-9]|4[47]|5[0129]|8[6-9])[0-9]{8}$/";

$str = "zhibin";

$preg = "/^[A-Za-z][A-z0-9]{5,7}$/";


$c = preg_match($preg, $str);


// var_dump($c);


// $mail = "asdf_90@sdfsd.com.cn";


// $preg = "/^[A-Za-z][A-z0-9-\.]{1,16}[A-Za-z0-9]@[A-Za-z0-9]([A-Za-z0-9]*|-?)(.[a-z]{2,8})+$/";


// $c = preg_match($preg, $mail);




// var_dump($c);
// 
// $str = "xueBBBBingsi";

// $preg = "/b{2,4}?/i";


// $res = preg_replace($preg, "c", $str);

// var_dump($res);
// var_dump($str);
// 

// $str =file_get_contents("https://www.lagou.com/"); //要操作的字符串




// $preg = "/<a href=\"(https:\/\/www\.lagou\.com\/jobs\/\d{7}\.html)\" target=\"_blank\"/";//规则 //原子组


// $c = preg_match_all($preg, $str , $out);

// var_dump($c);
// var_dump($out);


// $str = file_get_contents("https://www.lagou.com/jobs/2863301.html");

// var_dump($str);


// $preg= "/<h2 class=\"fl\">(.*?)<i class/s";


// $c = preg_match_all($preg, $str , $out);

// var_dump($c);
// var_dump($out);



$str = file_get_contents("http://www.jb51.net/article/31182.htm");

$str = mb_convert_encoding( $str, 'UTF-8', 'UTF-8,GBK,GB2312,BIG5' );

var_dump($str);


$preg= "/<h1 class=\"YaHei\">(.*)<\/h1>/";


$c = preg_match_all($preg, $str , $out);

var_dump($c);
var_dump($out);


$preg ="/<div id=\"content\">(.*)<div class=\"codetitle\">/s";


$c = preg_match_all($preg, $str , $out);

var_dump($c);
var_dump($out);


file_put_contents('./db.txt', $out[1][0]);















 ?>